package com.jketing.controller.spring.mvc.converter;

import java.util.ArrayList;
import java.util.List;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * StringToListConverter 自定义类型转化器
 * 
 * @author  李荣华
 * @version v1.0
 * @date    2018-01-02
 * @since   Spring-mvc 4.3.8
 */
@Component
public class StringToListConverter implements Converter<String, List<String>> {

	@Override
	public List<String> convert(String source) {
		List<String> list = new ArrayList<String>();
		if(source != null){
			String [] vals = source.split(",");
			if(vals != null){
				for(String id:vals) {
					list.add(id);
				}
				System.out.println(source + "--convert--" + list.toString());
			}
		}
		return list;
	}

}
